<?php

namespace app\admin\controller;

use app\common\controller\Base;
use think\Request;
use think\auth\Auth;
header('content-type:text/html;charset=utf-8');
class index extends Base
{
    /**
     * 显示资源列表
     *
     * @return \think\Response
     */
    public function index()
    {
        $data = db('menu')->field('name,title,id,pid')->select();
        $auth = new Auth();
        $tree = [];
        foreach ($data as $k=>$v){
            if($auth->check($v['name'],session('adminInfo.aid')) || session('adminInfo.aid') == 2){
                $tree[] = $v;
            }
        }
        $tree = get_trees($tree);
        $this->assign('tree',$tree);

        $datas = db('admin')->alias('a')->field('a.name,r.title')->join('role_admin ra','a.id = ra.aid')->join('role r','r.id = ra.rid')->where(['a.id' => session('adminInfo.aid')])->find();
        $this->assign('datas',$datas);
        return view();
    }
    public function main()
    {
        return view();
    }
}
